// src/api/notification.js
import request from "@/utils/request";

export default {

  // 添加通知
  addNotification(notification) {
    return request({
      url: "/notification/add",
      method: "post",
      data: notification,
    });
  },

  // 查询当前登录用户的所有通知
  getNotices(pageNo, pageSize) {
    return request({
      url: "/notification/page",
      method: "get",
      params:{
        pageNo: pageNo,
        pageSize: pageSize
      }
    });
  },

  // 根据 id 删除通知
  deleteNotificationById(id) {
    return request({
      url: `/notification/delete/${id}`,
      method: "delete",
    });
  },

  // 更新通知
  updateNotification(notification) {
    return request({
      url: "/notification/update",
      method: "put",
      data: notification,
    });
  },

  // 保存通知（新增或更新）
  saveNotification(notification) {
    if (notification.id) {
      return this.updateNotification(notification);
    } else {
      return this.addNotification(notification);
    }
  },
};